<template>
  <div class="detection-result">
    <!-- 页面头部 -->
    <div class="result-header">
      <div class="header-content">
        <div class="result-title">
          <h1>检测结果详情</h1>
          <div class="result-meta">
            <span class="result-id">ID: {{ resultData.id }}</span>
            <span class="result-time">{{ resultData.createdAt }}</span>
          </div>
        </div>
        <div class="result-actions">
          <button @click="downloadReport" class="action-btn primary">
            <i class="icon">📄</i>
            导出报告
          </button>
          <button @click="shareResult" class="action-btn secondary">
            <i class="icon">🔗</i>
            分享结果
          </button>
          <button @click="reAnalyze" class="action-btn">
            <i class="icon">🔄</i>
            重新分析
          </button>
        </div>
      </div>
    </div>

    <!-- 检测概览 -->
    <div class="detection-overview">
      <div class="overview-card">
        <div class="score-section">
          <div class="main-score" :class="getScoreClass(resultData.overallScore)">
            <div class="score-value">{{ resultData.overallScore }}</div>
            <div class="score-label">综合可信度</div>
          </div>
          <div class="score-description">
            <p>{{ getScoreDescription(resultData.overallScore) }}</p>
            <div class="confidence-level">
              <span class="level-label">置信度：</span>
              <span class="level-value">{{ resultData.confidence }}%</span>
            </div>
          </div>
        </div>
        
        <div class="quick-stats">
          <div class="stat-item">
            <div class="stat-value">{{ resultData.detectionType }}</div>
            <div class="stat-label">检测类型</div>
          </div>
          <div class="stat-item">
            <div class="stat-value">{{ resultData.processingTime }}秒</div>
            <div class="stat-label">处理时间</div>
          </div>
          <div class="stat-item">
            <div class="stat-value">{{ resultData.riskLevel }}</div>
            <div class="stat-label">风险等级</div>
          </div>
          <div class="stat-item">
            <div class="stat-value">{{ resultData.similarityCount }}</div>
            <div class="stat-label">相似内容</div>
          </div>
        </div>
      </div>
    </div>

    <!-- 详细分析结果 -->
    <div class="analysis-details">
      <div class="section-tabs">
        <button v-for="tab in detailTabs" :key="tab.id" 
                @click="activeDetailTab = tab.id" 
                :class="{ active: activeDetailTab === tab.id }"
                class="tab-btn">
          {{ tab.name }}
        </button>
      </div>

      <div class="tab-content">
        <!-- 文本分析 -->
        <div v-show="activeDetailTab === 'text'" class="text-analysis">
          <div class="analysis-section">
            <h3>情感分析</h3>
            <div class="sentiment-chart">
              <div class="sentiment-bar">
                <div class="sentiment-positive" :style="{ width: resultData.textAnalysis.sentiment.positive + '%' }"></div>
                <div class="sentiment-neutral" :style="{ width: resultData.textAnalysis.sentiment.neutral + '%' }"></div>
                <div class="sentiment-negative" :style="{ width: resultData.textAnalysis.sentiment.negative + '%' }"></div>
              </div>
              <div class="sentiment-labels">
                <span class="positive">积极 {{ resultData.textAnalysis.sentiment.positive }}%</span>
                <span class="neutral">中性 {{ resultData.textAnalysis.sentiment.neutral }}%</span>
                <span class="negative">消极 {{ resultData.textAnalysis.sentiment.negative }}%</span>
              </div>
            </div>
          </div>

          <div class="analysis-section">
            <h3>关键词提取</h3>
            <div class="keywords-cloud">
              <span v-for="keyword in resultData.textAnalysis.keywords" 
                    :key="keyword.word" 
                    class="keyword-tag"
                    :style="{ fontSize: keyword.weight + 'px' }">
                {{ keyword.word }}
              </span>
            </div>
          </div>

          <div class="analysis-section">
            <h3>语言特征</h3>
            <div class="features-grid">
              <div v-for="feature in resultData.textAnalysis.features" :key="feature.name" class="feature-item">
                <div class="feature-name">{{ feature.name }}</div>
                <div class="feature-progress">
                  <div class="progress-bar">
                    <div class="progress-fill" :style="{ width: feature.score + '%' }"></div>
                  </div>
                  <span class="feature-score">{{ feature.score }}%</span>
                </div>
              </div>
            </div>
          </div>
        </div>

        <!-- 图像分析 -->
        <div v-show="activeDetailTab === 'image'" class="image-analysis">
          <div class="analysis-section">
            <h3>图像检测结果</h3>
            <div class="image-results">
              <div v-for="(image, index) in resultData.imageAnalysis" :key="index" class="image-result-item">
                <div class="image-preview">
                  <img :src="image.url" :alt="'检测图像 ' + (index + 1)">
                  <div class="image-overlay">
                    <div class="detection-score" :class="getDetectionClass(image.manipulationScore)">
                      {{ image.manipulationScore }}%
                    </div>
                  </div>
                </div>
                <div class="image-details">
                  <h4>图像 {{ index + 1 }}</h4>
                  <div class="detection-items">
                    <div class="detection-item">
                      <span class="item-label">篡改检测</span>
                      <div class="item-score" :class="getDetectionClass(image.manipulationScore)">
                        {{ image.manipulationScore }}%
                      </div>
                    </div>
                    <div class="detection-item">
                      <span class="item-label">深度伪造</span>
                      <div class="item-score" :class="getDetectionClass(image.deepfakeScore)">
                        {{ image.deepfakeScore }}%
                      </div>
                    </div>
                    <div class="detection-item">
                      <span class="item-label">质量评估</span>
                      <div class="item-score quality">{{ image.quality }}%</div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>

        <!-- 相似内容 -->
        <div v-show="activeDetailTab === 'similarity'" class="similarity-analysis">
          <div class="analysis-section">
            <h3>相似内容匹配</h3>
            <div class="similarity-list">
              <div v-for="similar in resultData.similarityAnalysis" :key="similar.id" class="similarity-item">
                <div class="similarity-score">
                  <div class="score-circle" :style="{ background: getSimilarityColor(similar.score) }">
                    {{ similar.score }}%
                  </div>
                </div>
                <div class="similarity-content">
                  <h4>{{ similar.title }}</h4>
                  <p>{{ similar.description }}</p>
                  <div class="similarity-meta">
                    <span class="source">来源：{{ similar.source }}</span>
                    <span class="date">{{ similar.date }}</span>
                  </div>
                </div>
                <div class="similarity-actions">
                  <button @click="viewSimilar(similar)" class="view-btn">查看详情</button>
                </div>
              </div>
            </div>
          </div>
        </div>

        <!-- 技术分析 -->
        <div v-show="activeDetailTab === 'technical'" class="technical-analysis">
          <div class="analysis-section">
            <h3>技术指标</h3>
            <div class="technical-metrics">
              <div class="metric-card">
                <h4>算法置信度</h4>
                <div class="metric-value">{{ resultData.technicalAnalysis.algorithmConfidence }}%</div>
                <div class="metric-chart">
                  <div class="chart-bar" :style="{ width: resultData.technicalAnalysis.algorithmConfidence + '%' }"></div>
                </div>
              </div>
              <div class="metric-card">
                <h4>数据完整性</h4>
                <div class="metric-value">{{ resultData.technicalAnalysis.dataIntegrity }}%</div>
                <div class="metric-chart">
                  <div class="chart-bar" :style="{ width: resultData.technicalAnalysis.dataIntegrity + '%' }"></div>
                </div>
              </div>
              <div class="metric-card">
                <h4>模型准确率</h4>
                <div class="metric-value">{{ resultData.technicalAnalysis.modelAccuracy }}%</div>
                <div class="metric-chart">
                  <div class="chart-bar" :style="{ width: resultData.technicalAnalysis.modelAccuracy + '%' }"></div>
                </div>
              </div>
            </div>
          </div>

          <div class="analysis-section">
            <h3>处理日志</h3>
            <div class="process-log">
              <div v-for="log in resultData.processLog" :key="log.id" class="log-item">
                <div class="log-time">{{ log.timestamp }}</div>
                <div class="log-content">
                  <div class="log-level" :class="log.level">{{ log.level }}</div>
                  <div class="log-message">{{ log.message }}</div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>

    <!-- 建议措施 -->
    <div class="recommendations">
      <div class="recommendations-header">
        <h3>建议措施</h3>
        <div class="risk-indicator" :class="getRiskClass(resultData.riskLevel)">
          {{ resultData.riskLevel }}风险
        </div>
      </div>
      
      <div class="recommendations-grid">
        <div v-for="rec in resultData.recommendations" :key="rec.id" class="recommendation-card">
          <div class="rec-header">
            <div class="rec-priority" :class="rec.priority">{{ rec.priority }}</div>
            <div class="rec-type">{{ rec.type }}</div>
          </div>
          <div class="rec-content">
            <h4>{{ rec.title }}</h4>
            <p>{{ rec.description }}</p>
            <div class="rec-actions">
              <button v-if="rec.actionable" @click="executeRecommendation(rec)" class="rec-action-btn">
                执行建议
              </button>
              <button @click="learnMore(rec)" class="rec-learn-btn">了解更多</button>
            </div>
          </div>
        </div>
      </div>
    </div>

    <!-- 历史对比 -->
    <div class="history-comparison">
      <h3>历史对比分析</h3>
      <div class="comparison-chart">
        <div class="chart-container">
          <canvas ref="comparisonChart" width="800" height="300"></canvas>
        </div>
        <div class="chart-legend">
          <div class="legend-item">
            <div class="legend-color current"></div>
            <span>当前检测</span>
          </div>
          <div class="legend-item">
            <div class="legend-color average"></div>
            <span>平均水平</span>
          </div>
          <div class="legend-item">
            <div class="legend-color trend"></div>
            <span>趋势线</span>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, onMounted } from 'vue'

// 响应式数据
const activeDetailTab = ref('text')

// 详情标签页
const detailTabs = ref([
  { id: 'text', name: '文本分析' },
  { id: 'image', name: '图像分析' },
  { id: 'similarity', name: '相似内容' },
  { id: 'technical', name: '技术分析' }
])

// 检测结果数据
const resultData = ref({
  id: 'DR2024011501',
  createdAt: '2024-01-15 14:30:22',
  overallScore: 75,
  confidence: 88,
  detectionType: '组合检测',
  processingTime: 2.5,
  riskLevel: '中等',
  similarityCount: 8,
  textAnalysis: {
    sentiment: {
      positive: 25,
      neutral: 60,
      negative: 15
    },
    keywords: [
      { word: '突发事件', weight: 18 },
      { word: '官方确认', weight: 16 },
      { word: '网络传言', weight: 14 },
      { word: '真实情况', weight: 12 },
      { word: '权威发布', weight: 10 }
    ],
    features: [
      { name: '语言流畅度', score: 85 },
      { name: '逻辑一致性', score: 78 },
      { name: '情绪稳定性', score: 72 },
      { name: '专业术语', score: 65 }
    ]
  },
  imageAnalysis: [
    {
      url: 'https://example.com/image1.jpg',
      manipulationScore: 15,
      deepfakeScore: 8,
      quality: 92
    }
  ],
  similarityAnalysis: [
    {
      id: 1,
      title: '相关新闻报道',
      description: '官方媒体对此事件的报道内容',
      source: '新华网',
      date: '2024-01-14',
      score: 85
    },
    {
      id: 2,
      title: '类似事件分析',
      description: '历史上相似事件的处理情况',
      source: '人民日报',
      date: '2024-01-13',
      score: 72
    }
  ],
  technicalAnalysis: {
    algorithmConfidence: 88,
    dataIntegrity: 95,
    modelAccuracy: 92
  },
  processLog: [
    {
      id: 1,
      timestamp: '14:30:22',
      level: 'INFO',
      message: '开始文本预处理'
    },
    {
      id: 2,
      timestamp: '14:30:23',
      level: 'INFO',
      message: '完成情感分析'
    },
    {
      id: 3,
      timestamp: '14:30:24',
      level: 'WARN',
      message: '检测到可疑关键词'
    },
    {
      id: 4,
      timestamp: '14:30:25',
      level: 'INFO',
      message: '分析完成'
    }
  ],
  recommendations: [
    {
      id: 1,
      priority: '高',
      type: '验证建议',
      title: '核实信息来源',
      description: '建议通过官方渠道验证信息的真实性',
      actionable: true
    },
    {
      id: 2,
      priority: '中',
      type: '监控建议',
      title: '持续关注',
      description: '建议关注相关信息的后续发展',
      actionable: false
    }
  ]
})

// 方法
const getScoreClass = (score) => {
  if (score >= 80) return 'high'
  if (score >= 60) return 'medium'
  return 'low'
}

const getScoreDescription = (score) => {
  if (score >= 80) return '信息可信度较高，建议谨慎传播'
  if (score >= 60) return '信息可信度一般，建议进一步核实'
  return '信息可信度较低，建议避免传播'
}

const getDetectionClass = (score) => {
  if (score >= 70) return 'high-risk'
  if (score >= 30) return 'medium-risk'
  return 'low-risk'
}

const getSimilarityColor = (score) => {
  if (score >= 80) return '#4caf50'
  if (score >= 60) return '#ff9800'
  return '#f44336'
}

const getRiskClass = (risk) => {
  const riskMap = {
    '低': 'low',
    '中等': 'medium',
    '高': 'high'
  }
  return riskMap[risk] || 'medium'
}

const downloadReport = () => {
  console.log('下载报告')
}

const shareResult = () => {
  console.log('分享结果')
}

const reAnalyze = () => {
  console.log('重新分析')
}

const viewSimilar = (similar) => {
  console.log('查看相似内容:', similar)
}

const executeRecommendation = (rec) => {
  console.log('执行建议:', rec)
}

const learnMore = (rec) => {
  console.log('了解更多:', rec)
}

onMounted(() => {
  // 初始化图表
  drawComparisonChart()
})

const drawComparisonChart = () => {
  // 简单的图表绘制逻辑
  const canvas = document.querySelector('canvas')
  if (!canvas) return
  
  const ctx = canvas.getContext('2d')
  ctx.clearRect(0, 0, canvas.width, canvas.height)
  
  // 绘制趋势线
  ctx.beginPath()
  ctx.strokeStyle = '#1e3c72'
  ctx.lineWidth = 2
  ctx.moveTo(50, 200)
  ctx.lineTo(150, 180)
  ctx.lineTo(250, 160)
  ctx.lineTo(350, 140)
  ctx.lineTo(450, 120)
  ctx.stroke()
  
  // 绘制当前点
  ctx.beginPath()
  ctx.fillStyle = '#ff9800'
  ctx.arc(450, 120, 8, 0, 2 * Math.PI)
  ctx.fill()
}
</script>

<style scoped>
.detection-result {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

.result-header {
  background: linear-gradient(135deg, #1e3c72, #2a5298);
  color: white;
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 20px;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.result-title h1 {
  margin: 0 0 10px 0;
  font-size: 24px;
}

.result-meta {
  display: flex;
  gap: 20px;
  font-size: 14px;
  opacity: 0.9;
}

.result-actions {
  display: flex;
  gap: 10px;
}

.action-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 8px 16px;
  border: 1px solid rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.1);
  color: white;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.action-btn:hover {
  background: rgba(255,255,255,0.2);
}

.action-btn.primary {
  background: rgba(255,255,255,0.2);
  border-color: rgba(255,255,255,0.5);
}

.detection-overview {
  background: white;
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.overview-card {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 30px;
  align-items: center;
}

.score-section {
  display: flex;
  align-items: center;
  gap: 20px;
}

.main-score {
  text-align: center;
  padding: 20px;
  border-radius: 10px;
  background: #f8f9ff;
}

.score-value {
  font-size: 36px;
  font-weight: bold;
  margin-bottom: 5px;
}

.score-value.high {
  color: #4caf50;
}

.score-value.medium {
  color: #ff9800;
}

.score-value.low {
  color: #f44336;
}

.score-label {
  font-size: 14px;
  color: #666;
}

.score-description p {
  margin: 0 0 10px 0;
  color: #333;
}

.confidence-level {
  font-size: 14px;
  color: #666;
}

.level-value {
  font-weight: bold;
  color: #1e3c72;
}

.quick-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

.stat-item {
  text-align: center;
  padding: 15px;
  background: #f8f9ff;
  border-radius: 8px;
}

.stat-value {
  font-size: 18px;
  font-weight: bold;
  color: #1e3c72;
  margin-bottom: 5px;
}

.stat-label {
  font-size: 14px;
  color: #666;
}

.analysis-details {
  background: white;
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.section-tabs {
  display: flex;
  gap: 5px;
  margin-bottom: 20px;
}

.tab-btn {
  padding: 10px 20px;
  border: 1px solid #ddd;
  background: white;
  color: #666;
  border-radius: 5px 5px 0 0;
  cursor: pointer;
  transition: all 0.3s ease;
}

.tab-btn.active {
  background: #1e3c72;
  color: white;
  border-color: #1e3c72;
}

.tab-content {
  background: #f8f9ff;
  border-radius: 0 10px 10px 10px;
  padding: 20px;
  min-height: 400px;
}

.analysis-section {
  margin-bottom: 30px;
}

.analysis-section h3 {
  color: #1e3c72;
  margin-bottom: 15px;
}

.sentiment-chart {
  background: white;
  border-radius: 8px;
  padding: 15px;
}

.sentiment-bar {
  height: 20px;
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  margin-bottom: 10px;
}

.sentiment-positive {
  background: #4caf50;
}

.sentiment-neutral {
  background: #ff9800;
}

.sentiment-negative {
  background: #f44336;
}

.sentiment-labels {
  display: flex;
  gap: 20px;
  font-size: 14px;
}

.sentiment-labels .positive {
  color: #4caf50;
}

.sentiment-labels .neutral {
  color: #ff9800;
}

.sentiment-labels .negative {
  color: #f44336;
}

.keywords-cloud {
  background: white;
  border-radius: 8px;
  padding: 15px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.keyword-tag {
  background: #1e3c72;
  color: white;
  padding: 4px 12px;
  border-radius: 15px;
  font-size: 14px;
  display: inline-block;
}

.features-grid {
  display: grid;
  gap: 15px;
}

.feature-item {
  background: white;
  border-radius: 8px;
  padding: 15px;
  display: flex;
  align-items: center;
  gap: 15px;
}

.feature-name {
  min-width: 120px;
  font-weight: 600;
  color: #333;
}

.feature-progress {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
}

.progress-bar {
  flex: 1;
  height: 8px;
  background: #f0f0f0;
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #1e3c72, #2a5298);
  transition: width 0.3s ease;
}

.feature-score {
  font-weight: bold;
  color: #1e3c72;
}

.image-results {
  display: grid;
  gap: 20px;
}

.image-result-item {
  background: white;
  border-radius: 8px;
  padding: 15px;
  display: flex;
  gap: 20px;
}

.image-preview {
  position: relative;
  flex-shrink: 0;
}

.image-preview img {
  width: 200px;
  height: 150px;
  object-fit: cover;
  border-radius: 8px;
}

.image-overlay {
  position: absolute;
  top: 10px;
  right: 10px;
}

.detection-score {
  background: rgba(0,0,0,0.8);
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: bold;
}

.image-details {
  flex: 1;
}

.image-details h4 {
  margin: 0 0 15px 0;
  color: #1e3c72;
}

.detection-items {
  display: grid;
  gap: 10px;
}

.detection-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px;
  background: #f8f9ff;
  border-radius: 5px;
}

.item-label {
  font-weight: 600;
  color: #333;
}

.item-score {
  font-weight: bold;
  padding: 2px 8px;
  border-radius: 3px;
}

.item-score.high-risk {
  background: #ffebee;
  color: #f44336;
}

.item-score.medium-risk {
  background: #fff3e0;
  color: #ff9800;
}

.item-score.low-risk {
  background: #e8f5e8;
  color: #4caf50;
}

.item-score.quality {
  background: #e3f2fd;
  color: #2196f3;
}

.similarity-list {
  display: grid;
  gap: 15px;
}

.similarity-item {
  background: white;
  border-radius: 8px;
  padding: 15px;
  display: flex;
  align-items: center;
  gap: 15px;
}

.similarity-score {
  flex-shrink: 0;
}

.score-circle {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  color: white;
  font-size: 14px;
}

.similarity-content {
  flex: 1;
}

.similarity-content h4 {
  margin: 0 0 5px 0;
  color: #333;
}

.similarity-content p {
  margin: 0 0 10px 0;
  color: #666;
  font-size: 14px;
}

.similarity-meta {
  display: flex;
  gap: 20px;
  font-size: 12px;
  color: #999;
}

.similarity-actions {
  flex-shrink: 0;
}

.view-btn {
  background: #1e3c72;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.3s ease;
}

.view-btn:hover {
  background: #2a5298;
}

.technical-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 30px;
}

.metric-card {
  background: white;
  border-radius: 8px;
  padding: 20px;
  text-align: center;
}

.metric-card h4 {
  margin: 0 0 10px 0;
  color: #333;
}

.metric-value {
  font-size: 24px;
  font-weight: bold;
  color: #1e3c72;
  margin-bottom: 15px;
}

.metric-chart {
  height: 8px;
  background: #f0f0f0;
  border-radius: 4px;
  overflow: hidden;
}

.chart-bar {
  height: 100%;
  background: linear-gradient(90deg, #1e3c72, #2a5298);
  transition: width 0.3s ease;
}

.process-log {
  background: white;
  border-radius: 8px;
  padding: 15px;
  max-height: 300px;
  overflow-y: auto;
}

.log-item {
  display: flex;
  gap: 15px;
  padding: 8px 0;
  border-bottom: 1px solid #f0f0f0;
}

.log-time {
  font-size: 12px;
  color: #666;
  min-width: 70px;
}

.log-content {
  flex: 1;
  display: flex;
  gap: 10px;
}

.log-level {
  font-size: 12px;
  font-weight: bold;
  padding: 2px 6px;
  border-radius: 3px;
  min-width: 50px;
  text-align: center;
}

.log-level.INFO {
  background: #e3f2fd;
  color: #2196f3;
}

.log-level.WARN {
  background: #fff3e0;
  color: #ff9800;
}

.log-level.ERROR {
  background: #ffebee;
  color: #f44336;
}

.log-message {
  color: #333;
  font-size: 14px;
}

.recommendations {
  background: white;
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.recommendations-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.recommendations-header h3 {
  color: #1e3c72;
  margin: 0;
}

.risk-indicator {
  padding: 6px 12px;
  border-radius: 15px;
  font-size: 14px;
  font-weight: bold;
}

.risk-indicator.low {
  background: #e8f5e8;
  color: #4caf50;
}

.risk-indicator.medium {
  background: #fff3e0;
  color: #ff9800;
}

.risk-indicator.high {
  background: #ffebee;
  color: #f44336;
}

.recommendations-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
}

.recommendation-card {
  background: #f8f9ff;
  border-radius: 8px;
  padding: 20px;
  border-left: 4px solid #1e3c72;
}

.rec-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.rec-priority {
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: bold;
}

.rec-priority.高 {
  background: #ffebee;
  color: #f44336;
}

.rec-priority.中 {
  background: #fff3e0;
  color: #ff9800;
}

.rec-priority.低 {
  background: #e8f5e8;
  color: #4caf50;
}

.rec-type {
  font-size: 12px;
  color: #666;
}

.rec-content h4 {
  margin: 0 0 10px 0;
  color: #333;
}

.rec-content p {
  margin: 0 0 15px 0;
  color: #666;
  font-size: 14px;
}

.rec-actions {
  display: flex;
  gap: 10px;
}

.rec-action-btn,
.rec-learn-btn {
  padding: 6px 12px;
  border: 1px solid #1e3c72;
  border-radius: 5px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.3s ease;
}

.rec-action-btn {
  background: #1e3c72;
  color: white;
}

.rec-action-btn:hover {
  background: #2a5298;
}

.rec-learn-btn {
  background: white;
  color: #1e3c72;
}

.rec-learn-btn:hover {
  background: #f8f9ff;
}

.history-comparison {
  background: white;
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.history-comparison h3 {
  color: #1e3c72;
  margin-bottom: 20px;
}

.comparison-chart {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.chart-container {
  text-align: center;
}

.chart-legend {
  display: flex;
  justify-content: center;
  gap: 20px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.legend-color {
  width: 12px;
  height: 12px;
  border-radius: 2px;
}

.legend-color.current {
  background: #ff9800;
}

.legend-color.average {
  background: #4caf50;
}

.legend-color.trend {
  background: #1e3c72;
}

@media (max-width: 768px) {
  .detection-result {
    padding: 10px;
  }
  
  .header-content {
    flex-direction: column;
    gap: 15px;
  }
  
  .result-actions {
    width: 100%;
    justify-content: center;
  }
  
  .overview-card {
    grid-template-columns: 1fr;
  }
  
  .quick-stats {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .technical-metrics {
    grid-template-columns: 1fr;
  }
  
  .recommendations-grid {
    grid-template-columns: 1fr;
  }
  
  .image-result-item {
    flex-direction: column;
  }
  
  .image-preview img {
    width: 100%;
  }
}
</style> 